﻿public class ObstacleGapNull : ObstacleGap
{
    public ObstacleGapNull() : base(null, 0) { }

    public override bool hasPassedTheGap()
    {
        return true;
    }
}

public class ObstacleGap
{
    private float gap;
    private Obstacle obstacle;

    public ObstacleGap(Obstacle _obstacle, float _gap)
    {
        obstacle = _obstacle;
        gap = -_gap;
    }

    public virtual bool hasPassedTheGap()
    {
        bool passedTheGap = false;

        if (positionHasPassedTheGap())
            passedTheGap = true;

        return passedTheGap;
    }

    private bool positionHasPassedTheGap()
    {
        return obstacle.transform.localPosition.x < gap;
    }
}